const router = require('koa-router')();
const book = require('../modules/book');

//获取数据
router.get('/book',async(ctx,next) => {
    ctx.body = await book.getBook();
})
//增加数据
router.post('/book',async(ctx,next) => {
    ctx.body = await book.addBook(ctx.request.body);
})
//删除数据
router.delete('/book/:subjects/:book_name',async(ctx,next) => {
    ctx.body = await book.deleteBook(ctx.params);
})
//修改数据
router.put('/book',async(ctx,next)=>{
    ctx.body = await book.putBook(ctx.request.body);
})

module.exports = router;
